package com.xr.org.emp;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.xr.common.CommUtil;

/**
 * rAndPListViewModel
 */
public class rAndPListViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds = getDataset("datasetRandP");
	  ds.moveFirst();
	  while(!ds.isLast()){
		  ds.setValue("MODIFY_DATE", new java.util.Date());
		  ds.setValue("MODIFY_ID", CommUtil.getEmployeeId());
		  ds.moveNext();
	  }
	  ds.moveFirst();
  CommUtil.dbsUpdateData(dbs, ds, "emp_randp", "EMP_RANDP_ID");
  dbs.close();
  //  super.doUpdateData(parameters, outParameters);
  }
  public void rAndpAdd(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds = getDataset("datasetRandP");
	  Dataset dsEmp = getDataset("datasetQueryEmployee");
	  dsEmp.moveFirst();
	  while(!dsEmp.isLast()){
		  ds.setValue("CREATE_DATE", new java.util.Date());
		  ds.setValue("CREATE_ID", CommUtil.getEmployeeId());
		  ds.setValue("ONOFF_STATION_ID", dsEmp.getValue("ONOFF_STATION_ID"));
		  ds.setValue("EMPLOYEE_ID", dsEmp.getValue("EMPLOYEE_ID"));
		  ds.setRecordState(Record.STATE_NEW);
		  ds.setValue("EMP_RANDP_ID", "");
		  CommUtil.dbsUpdateData(dbs, ds, "emp_randp", "EMP_RANDP_ID");
		  dsEmp.moveNext();
	  }
  dbs.close();
//super.doUpdateData(parameters, outParameters);
}
  public void dr(ParameterSet parameters, ParameterSet outParameters)
  throws Exception {
	  DBStatement dbs = new DBStatement();
	  Dataset ds = getDataset("datasetRandP");
	  dbs.setSql("update emp_randp set dr=1 where EMP_RANDP_ID="+ds.getString("EMP_RANDP_ID"));
	  dbs.execute();
	  dbs.close();
}
}
